﻿using Microsoft.Reporting.WinForms;
using RecruitStudents.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Report
{
    public partial class Report_Print : BaseForm
    {
        private DataTable ReportDataSources;
        private string ReportTitle;
        private string ReportSubTitle;
        private string Remark;
        public Report_Print(DataTable dtReportDataSources,string strRptTitle,string strRptSubTitle,string strRemark)
        {
            InitializeComponent();
            ReportDataSources = dtReportDataSources;
            ReportTitle = strRptTitle;
            ReportSubTitle = strRptSubTitle;
             Remark= strRemark;
        }

        private void LoadPrintStudentYUYUEReport()
        {
            try
            {
                this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                this.reportViewer1.LocalReport.ReportPath = "Report/AllowExamID_Act.rdlc";
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1";
                reportDataSource.Value = ReportDataSources;
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(reportDataSource);

                ReportParameter rptTitle = new ReportParameter("rptTitle", ReportTitle);
                ReportParameter rptSubTitle = new ReportParameter("rptSubTitle", ReportSubTitle);
                ReportParameter rptPrintDate = new ReportParameter("rptPrintDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                ReportParameter rptRemark = new ReportParameter("rptRemark", Remark);

                reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rptTitle, rptSubTitle, rptPrintDate, rptRemark });
                reportViewer1.Width = 1000;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            { }
        }
        private void Report_Print_Load_1(object sender, EventArgs e)
        {
            LoadPrintStudentYUYUEReport();

            this.reportViewer1.RefreshReport();
        } 

        private void reportViewer1_PrintingBegin(object sender, ReportPrintEventArgs e)
        {
            try
            {
                this.Close();
            }
            catch
            { }
        }
    }
}
